home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / Include / sched.h < prev    next >
C/C++ Source or Header  |  1990-12-07  |  5KB  |  162 lines

  1. /*
  2.  * sched.h --
  3.  *
  4.  *    Declarations of procedures exported by the sched module.
  5.  *
  6.  * Copyright 1985 Regents of the University of California
  7.  * All rights reserved.
  8.  *
  9.  *
  10.  * rcsid $Header: /sprite/src/kernel/sched/RCS/sched.h,v 9.5 90/12/07 15:02:44 mgbaker Exp $ SPRITE (Berkeley)
  11.  */
  12.  
  13. #ifndef _SCHED
  14. #define _SCHED
  15.  
  16. #ifdef KERNEL
  17. #include <timer.h>
  18. #include <proc.h>
  19. #include <mach.h>
  20. #include <sync.h>
  21. #else
  22. #include <kernel/timer.h>
  23. #include <kernel/proc.h>
  24. #include <kernel/mach.h>
  25. #include <kernel/sync.h>
  26. #endif
  27.  
  28. /*
  29.  * Flags for the schedFlags in the proc table.
  30.  *
  31.  *    SCHED_CONTEXT_SWITCH_PENDING    A context switch came in while context
  32.  *                    switching was disabled.
  33.  *    SCHED_CLEAR_USAGE        Clear usage information for this
  34.  *                    process when scheduling it.  Intended
  35.  *                    to be used by kernel worker processes.
  36.  *    SCHED_STACK_IN_USE        The stack of this process is being
  37.  *                    used by a processor.  The processor 
  38.  *                    field of the Proc_ControlBlock 
  39.  *                    specifies what processor is using it. 
  40.  */
  41.  
  42. #define SCHED_CONTEXT_SWITCH_PENDING    0x1
  43. #define    SCHED_CLEAR_USAGE        0x2    
  44. #define    SCHED_STACK_IN_USE        0x4
  45.  
  46. typedef struct Sched_Instrument {
  47.     /*
  48.      * Per processor numbers.
  49.      */
  50.     struct perProcessor {
  51.     /* 
  52.      * Total number of context switches. 
  53.      */
  54.     int    numContextSwitches;        
  55.     
  56.     /* 
  57.      * Only those due to end of quantum. 
  58.      */
  59.     int    numInvoluntarySwitches;    
  60.     
  61.     /* 
  62.      * Number of switches that cause a different process to run.
  63.      */
  64.     int numFullCS;            
  65.  
  66.     /* 
  67.      * Amount of time w/o running process.  
  68.      */
  69.     Timer_Ticks noProcessRunning;    
  70.     
  71.     /* 
  72.      * Converted value of noProcessRunning that is only computed when
  73.      * this struct is copied out to user space.
  74.      */
  75.     Time idleTime;            
  76.     
  77.     /* 
  78.      * Free running counter that is ++'d inside the idle loop.  It is used
  79.      * to measure CPU utilization.
  80.      */
  81.     unsigned int idleTicksLow;        
  82.     /* 
  83.      * Make the counter into 64 bits 
  84.      */
  85.     unsigned int idleTicksOverflow;
  86.         unsigned int idleTicksPerSecond;    /* Calibrated value */
  87.  
  88. #if     (MACH_MAX_NUM_PROCESSORS != 1) 
  89.     /*
  90.      * Pad the structure to insure that two structure occur in the
  91.      * same cache block.  This is to prevent pinging of cache blocks
  92.      * between processor in a multiprocessor such as SPUR while 
  93.      * incrementing the IdleLoop counter.
  94.      */
  95.      Mach_CacheBlockSizeType    pad;
  96. #endif
  97.     } processor[MACH_MAX_NUM_PROCESSORS];
  98.  
  99.     int numReadyProcesses;        /* Number of ready processes at time
  100.                      * of call to copy information */
  101.  
  102.     Time noUserInput;            /* Time since last level-6 interrupt */
  103. } Sched_Instrument;
  104.  
  105. #ifdef SOSP91
  106. /*
  107.  * Overall user and system times, not just per process.  If we like having
  108.  * this info, we should put it into Sched_Instrument.
  109.  */
  110. typedef struct  Sched_OverallTimes {
  111.     Timer_Ticks kernelTime;
  112.     Timer_Ticks userTime;
  113.     Timer_Ticks userTimeMigrated;
  114. } Sched_OverallTimes;
  115.  
  116. extern    Sched_OverallTimes      sched_OverallTimesPerProcessor[];
  117.  
  118. #endif SOSP91
  119.  
  120.  
  121. typedef struct {
  122.     Proc_ControlBlock        *procPtr;
  123. #if     (MACH_MAX_NUM_PROCESSORS != 1) 
  124.    Mach_CacheBlockSizeType    pad;
  125. #endif
  126. } Sched_OnDeck;
  127.  
  128. extern Sched_OnDeck    sched_OnDeck[MACH_MAX_NUM_PROCESSORS];
  129.  
  130. /*
  131.  * External declarations:
  132.  */
  133.     
  134. extern Sync_Semaphore sched_Mutex;    /* Mutual exclusion in scheduler */
  135.  
  136. extern Sync_Semaphore *sched_MutexPtr;
  137. extern Sched_Instrument sched_Instrument;   /* Counters for instrumentation. */
  138. extern int sched_Quantum;        /* Timer interrupts per quantum. */
  139. extern Sched_OnDeck    sched_OnDeck[MACH_MAX_NUM_PROCESSORS];
  140.  
  141. extern void Sched_MakeReady _ARGS_((register Proc_ControlBlock *procPtr));
  142. extern void Sched_StartUserProc _ARGS_((Address pc));
  143. extern void Sched_StartKernProc _ARGS_((void (*func)()));
  144. extern void Sched_ContextSwitch _ARGS_((Proc_State state));
  145. extern void Sched_ContextSwitchInt _ARGS_((register Proc_State state));
  146. extern void Sched_ForgetUsage _ARGS_((Timer_Ticks time, ClientData clientData));
  147. extern void Sched_GatherProcessInfo _ARGS_((unsigned int interval));
  148. extern void Sched_Init _ARGS_((void));
  149. extern void Sched_TimeTicks _ARGS_((void));
  150. extern void Sched_LockAndSwitch _ARGS_((void));
  151. extern ReturnStatus Sched_StartProcessor _ARGS_((int pnum));
  152. extern ReturnStatus Sched_IdleProcessor _ARGS_((int pnum));
  153. extern void Sched_InsertInQueue _ARGS_((Proc_ControlBlock *procPtr, 
  154.                     Proc_ControlBlock **runPtrPtr));
  155. extern void Sched_PrintStat _ARGS_((void));
  156. extern void Sched_SetClearUsageFlag _ARGS_((void));
  157. extern void Sched_DumpReadyQueue _ARGS_((ClientData dummy));
  158. extern void Sched_StartSchedStats _ARGS_((void));
  159. extern void Sched_StopSchedStats _ARGS_((void));
  160.  
  161. #endif /* _SCHED */
  162.